#ifndef __zbStructs_H
#define __zbStructs_H

/* Circular buffer object */
typedef struct {
    int         size;   /* maximum number of elements           */
    int         start;  /* index of oldest element              */
    int         count;   
    u8          *elems;  /* vector of elements                   */
} CircularBuffer;

#pragma pack(push, 1)
typedef struct{
	u8 	ID;
	u8 	TXN;
	u8 	CMD;
	u8 	FLG;
	u16	SIZE;
}pktHdr;
#pragma pack(pop)

typedef enum{
	new = 0x01,
	data = 0x02,
	done = 0x03
}statesEnum;
	

typedef struct{
	u8 		*txHdr;	    // header to send
	u8		*offset;	// offset to start sending payload
	u16		count;		// how much to send from offset
	statesEnum state;  
}dmaPush;

#pragma pack(push, 1)
// size 81 bytes
typedef struct glbVars
{
	// READ VARIABLES ********************************************
	 
	// enviromental
	u16 modelInfo;		// type of model, software version
	u16 versionInfo;	// version number
	u32 status;			// current status including errors
	u32 update;			// zbot requests you update something 
	
	// adc conversions
	u32 ADCIN1;			// 
	u32 ADCIN2;			// 
	u32 FQ1;			// captures the frequency on this pin

	// ReadWrite Variables, we will read often, write rarely
														
	// enviromental
	u32 gpioRead;	  	// live values of readable gpio
	u32 seconds;	  	// current seconds 
	u32 milliseconds;  	// current milliseconds
	u32 i2cRXBuff;		// last rx command from i2c

	// some space for a few future use vars
	u32 FutureR1;			//	future use ? 
	u32 FutureR2;			//	future use ? 
	
	// WRITE VARIABLES (CAN BE READ ALSO) ***********************

	u32 enabled;		// what perih are enabled
	u32 gpioWrite;		// write to gpio 
	// pwm motor control ? 
	u8 PWMOUTCH1Duty;	   	// 
	u8 PWMOUTCH2Duty;
	u8 PWMOUTCH3Duty;
	u8 PWMOUTCH4Duty;
	u8 PWMOUTCH5Duty; 
	u8 PWMOUTCH6Duty; 
	u8 PWMOUTCH7Duty; 
	u8 PWMOUTCH8Duty;  
	u32 PWMOUTFQ;		   	// frequency of pwm
	// video 
	u16 VideoWidth;
	u16 VideoHeight; // todo implement changing !
	u8 VideoBPP;	// bytes per pixel
	u8 VideoFmt;   // rgb, yuv etc
	u8 VideoStat;	// what status (internal only!)
	 
	// not used yet
	u32 i2cTXBuff;	   	// data sent to i2c bus
	u32 DAC1;			// dac1 
	u32 DAC2;			// dac2 
	// some space for a few future use vars
	u32 FutureW1;		//	future use ? 
	u32 FutureW2;		//	future use ? 

	// read only, info only ! 
	u32 dataState;		// current state of data tx/rx in main
	

} globalVars, *pgloabalVars;
#pragma pack(pop)

#endif

